<?php
class Ti extends Model{
	protected $table_name = 'ti';
	
	public function test(){
		echo 'Ti model test!<br/>';
	}
	
	//获取题目   @param:string/array    @return:array
	public function ti_by_ids($ids){
		if(is_string($ids)) $ids = explode('|',$ids);
		$re = array();
		foreach($ids as $id) {
			if(empty($id)) continue;
			$ti = $this->find(array('id'=>$id),'id,ti');
			$re = array_merge($re,array($ti));
		}
		return $re;
	}
	
	//增加一个新题目  先去重
	public function add_one($ti,$time=''){
		$ti = trim($ti);
		$re = $this->find(array('ti'=>$ti),'id');
		if(!empty($re['id'])) return $re['id'];

		if(empty($time)) $time= time();
		return $this->insert(array('ti'=>$ti,'cr_time'=>$time));
	}
	
	
	
	
	
	
	
}
?>